package com.mxpio.erp.common.inventory.entity;

import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.jpa.annotation.DictAble;
import com.mxpioframework.security.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

@Data
@Entity
@Table(name = "v_mb_erp_inv_stock_hold")
@Schema(description="实时库存（带领用申请占用）")
@NoArgsConstructor
@AllArgsConstructor
public class VInvStockHold implements DictAble, Serializable {

	private static final long serialVersionUID = 1L;

	/*public VInvStockHold(String itemCode, String whCode, BigDecimal quantity, BigDecimal borrowedQuantity){
		this.itemCode = itemCode;
		this.whCode = whCode;
		this.quantity = quantity;
		this.borrowedQuantity = borrowedQuantity;
	}

	//库存汇总，带字段名称
	public VInvStockHold(String itemCode, String whCode, String itemName, String itemGroupCode, String itemSpec, String unitCode, BigDecimal quantity, BigDecimal borrowedQuantity){
		this.itemCode = itemCode;
		this.whCode = whCode;
		this.itemName = itemName;
		this.itemGroupCode = itemGroupCode;
		this.itemSpec = itemSpec;
		this.unitCode = unitCode;
		this.quantity = quantity;
		this.borrowedQuantity = borrowedQuantity;
	}*/
	@Id
	@Column(name = "ITEM_CODE_")
	@Schema(description = "物料代码")
	private String itemCode;
	@Id
	@Column(name = "WH_CODE_")
	@Schema(description = "仓库代码")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String whCode;
	
	@Column(name = "QUANTITY_")
	@Schema(description = "数量")
	private BigDecimal quantity;
	
	@Column(name = "BORROWED_QUANTITY_")
	@Schema(description = "已借出数量")
	private BigDecimal borrowedQuantity;

	@Column(name = "HOLD_QUANTITY_")
	@Schema(description = "已锁定数量")
	private BigDecimal holdQuantity;

	@Column(name = "AVAILABLE_QUANTITY_")
	@Schema(description = "可用数量")
	private BigDecimal availableQuantity;

	@Column(name = "ITEM_NAME_")
	@Schema(description = "物料名称")
	private String itemName;

	@Column(name = "ITEM_GROUP_CODE_")
	@Schema(description = "物料组")
	@Dict(dicCode="groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
	private String itemGroupCode;

	@Column(name = "ITEM_SPEC_")
	@Schema(description = "物料规格")
	private String itemSpec;

	@Column(name = "UNIT_CODE_")
	@Schema(description = "单位编号")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
	private String unitCode;

	@Column(name = "IMG_FILE_")
	@Schema(description = "图片路径")
	private String imgFile;
	@Transient
	private Map<String, String> textMap;

	public String putText(String key, String value) {
		if (textMap == null) {
			textMap = new HashMap<>();
		}
		return textMap.put(key, value);
	}

}
